/**
 * 系统配置文件
 * User: Vector Ho
 * Date: 2014-06-05
 * Time: 下午2:29
 * To change this template use File | Settings | File Templates.
 *      系统配置文件
 */


var currentDir = __dirname.replace(/\\/g, '/');
var lastIndex = currentDir.lastIndexOf('/');

/**
 * 网站根目录
 * @type {string}
 */
exports.ROOT_PATH = currentDir.slice(0, lastIndex);



/**
 * redis库配置
 * @type {{port: string, host: string, options: {connect_timeout: string}}}
 */
exports.redisConfig = {
    'host': '10.144.0.73',
    'port': 6379,
    'connect_timeout': 8000
};

// mongodb://user:pass@localhost:port/database
exports.mongooseConfig = "mongodb://10.144.0.73/zillaInstant";

/**
 * mongodb库配置：原生驱动
 * @type {{host: string, port: string, options: {auto_reconnect: boolean, poolSize: number}, database: string}}
 */
// exports.mongodbConfig = {
//     'host': 'yezhiming.com',
//     'port': '27017',
//     'options': {
//         'auto_reconnect': true,
//         'poolSize': 10
//     },
//     'database': 'zillaInstant'
// };


/**
 * MODEL文件夹路径
 * @type {string}
 */
exports.MODEL_PATH = this.ROOT_PATH + '/model/';

/**
 * lib文件夹路径
 * @type {string}
 */
exports.LIB_PATH = this.ROOT_PATH + '/helper/';

exports.APP_ID = "43ea5ef81c2e036a93de068f7dd739be";
exports.APP_SECRET = "ab3194ab-c4c9-4b1f-9a99-5a625bae2c60";

/**
 * zookeeper cli
 * @type {Object}
 */
exports.zookeeperConf = {
    'connectionString': '172.16.1.43:2181',
    'options': {
        sessionTimeout: 10000,
        spinDelay: 3000,
        retries: 1
    },
    'sessionPath': '/instant/session',
    'routerPath': '/instant/router'
}

/** 本机真实网络
 * [os description]
 * @type {[type]}
 */
var os = require('os');
exports.hardware = {
    'networkInterfaces': os.networkInterfaces,
    'internetFace': function() {
        var result = [];
        var objs = this.networkInterfaces();
        delete objs.lo0; // 排除回环地址
        for (var obj in objs) {
            if (objs.hasOwnProperty(obj) && Array.isArray(objs[obj])) {
                result.push(objs[obj].map(function(eth) {
                    return eth.address;
                }).filter(function(address) {
                    return (address !== '127.0.0.1') && (address.indexOf('::') === -1) && (address.indexOf('10.') === -1) && (address.indexOf('192.') === -1) && (address.indexOf('172.') === -1);
                }));
            }
        };
        return result;
    }
}

/**
 * log文件夹路径：pm2替代
 * @type {string}
 */
// exports.LOG_PATH = this.ROOT_PATH + '/log/';
